package starcoast.bocai.com.starcoast.activitys.work;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

import butterknife.Bind;
import butterknife.ButterKnife;
import starcoast.bocai.com.starcoast.R;
import starcoast.bocai.com.starcoast.common.BaseActivity;
import starcoast.bocai.com.starcoast.view.SelectPopupWindow;

/**
 * Created by admin on 2016/6/13.
 */
public class PurchaseDetailActivity extends BaseActivity implements View.OnClickListener {
    @Bind(R.id.check_color)
    LinearLayout check_color;
    SelectPopupWindow selectPopupWindow;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_purchase_detail);
        ButterKnife.bind(this);
        check_color.setOnClickListener(this);
        selectPopupWindow = new SelectPopupWindow(this);
        selectPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
            @Override
            public void onDismiss() {
                backgroundAlpha((float)1);
            }
        });
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.check_color:
                //显示窗口
                backgroundAlpha((float)0.5);
                selectPopupWindow.showAtLocation(this.findViewById(R.id.main), Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL, 0, 0); //设置layout在PopupWindow中显示的位置
                break;
        }
    }
    public void backgroundAlpha(float bgAlpha)
    {
        WindowManager.LayoutParams lp = getWindow().getAttributes();
        lp.alpha = bgAlpha; //0.0-1.0
        getWindow().setAttributes(lp);
    }

}
